# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=mmtf-cpp
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.1.0
pkgrel=1
pkgdesc="The pure C++ implementation of the MMTF API, decoder and encoder. (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://mmtf.rcsb.org'
msys2_repository_url="https://github.com/rcsb/mmtf-cpp"
msys2_references=(
  'archlinux: mmtf-cpp'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-msgpack-cxx")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=("https://github.com/rcsb/mmtf-cpp/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('021173bdc1814b1d0541c4426277d39df2b629af53151999b137e015418f76c0')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
}

build() {
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    "${MINGW_PREFIX}"/bin/cmake.exe \
      -GNinja \
      -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
      -S "${_realname}-${pkgver}" \
      -B "build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/cmake.exe --build "build-${MSYSTEM}"
}

package() {
  DESTDIR="${pkgdir}" "${MINGW_PREFIX}"/bin/cmake.exe --install "build-${MSYSTEM}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
